package com.aids_malaria.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.aids_malaria.http.response.AreaV;

import java.util.List;

@Dao
public interface AreaVDao {
    @Query("delete from areaV")
    int deleteAll();

    @Query("SELECT * FROM areaV")
    List<AreaV> getAll();

    @Query("SELECT * FROM areaV WHERE createOrUpdate =:isCreateUpdate")
    List<AreaV> getAllByCreateUpdate(boolean isCreateUpdate);

    @Query("SELECT * FROM areaV WHERE county_code == :countyCode")
    List<AreaV> getAllByCountyCode(String countyCode);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    List<Long> insertAll(List<AreaV> users);



    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Long insert(AreaV users);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    int update(AreaV user);


    @Query("SELECT * FROM areaV WHERE village_name IN (:village_name)")
    List<AreaV> getByVillageName(String village_name);

    @Query("SELECT * FROM areaV WHERE village_name IN (:village_name) AND county_code == :countyCode")
    List<AreaV> getByVillageNameAndCountyCode(String village_name, String countyCode);
}

